package com.yyfax.common.form;

import android.content.Context;

import com.yyfax.common.tools.RegularExpress;
import com.yyfax.common.tools.Toaster;

/**
 * Created by fuqiang on 2017/5/4.
 * 金额校验
 * Copyright  2017 www.yylending.com. All Rights Reserved.
 */
public class AmountValidate {

    public static boolean validate(Context context, ClearEditText clearEditText, NoticeText noticeText) {

        if (RegularExpress.isEmpty(clearEditText)) {
            Toaster.showShortToast(context, noticeText.mEmptyMsg);
            return false;
        }
        clearEditText.parseAmount();
        if (clearEditText.getmAmount() <= 0) {
            Toaster.showShortToast(context, noticeText.mExpressionMsg);
            return false;
        }
        //超出范围
        if (clearEditText.getmAmount() > clearEditText.getRemain()) {
            Toaster.showShortToast(context, noticeText.mOverRangeMsg);
            return false;
        }
        //是否为1000的整数倍
        if (clearEditText.getmAmount() % 1000 != 0) {
            Toaster.showShortToast(context, noticeText.mAmountMsg);
            return false;
        }
        return true;
    }
}
